package org.dakuo.sgfyModel;

public class SgfyResource {
	public static final String RESOURCE_LUMBER = "木头";
	public static final String RESOURCE_CLAY = "石头";
	public static final String RESOURCE_IRON = "铁矿";
	public static final String RESOURCE_CROP = "粮食";
	public static final String RESOURCE_POPULATION = "人口";

	private String name;
	private float now;
	private float max;
	private float speed;
	private float increase;
	private float buff;

	public SgfyResource() {
		this.setName("");
		this.setNow(0);
		this.setMax(0);
		this.setSpeed(0);
		this.setIncrease(0);
		this.setBuff(0);
	}

	public SgfyResource(String name, float now, float max, float speed,
			float increase, float buff) {
		String nameCN;
		if(name.equalsIgnoreCase("lumber")){
			nameCN = RESOURCE_LUMBER;
		}
		else if(name.equalsIgnoreCase("clay")){
			nameCN = RESOURCE_CLAY;
		}
		else if(name.equalsIgnoreCase("iron")){
			nameCN = RESOURCE_IRON;
		}
		else if(name.equalsIgnoreCase("crop")){
			nameCN = RESOURCE_CROP;
		}
		else if(name.equalsIgnoreCase("population")){
			nameCN = RESOURCE_POPULATION;
		}
		else{
			nameCN = " ";
		}
		this.setName(nameCN);
		this.setNow(now);
		this.setMax(max);
		this.setSpeed(speed);
		this.setIncrease(increase);
		this.setBuff(buff);
	}

	public SgfyResource(String name) {
		this.setName(name);
	}

	public SgfyResource(String name, String now, String max,
			String speed, String increse, String buff) {
		String nameCN;
		if(name.equalsIgnoreCase("lumber")){
			nameCN = RESOURCE_LUMBER;
		}
		else if(name.equalsIgnoreCase("clay")){
			nameCN = RESOURCE_CLAY;
		}
		else if(name.equalsIgnoreCase("iron")){
			nameCN = RESOURCE_IRON;
		}
		else if(name.equalsIgnoreCase("crop")){
			nameCN = RESOURCE_CROP;
		}
		else if(name.equalsIgnoreCase("population")){
			nameCN = RESOURCE_POPULATION;
		}
		else{
			nameCN = " ";
		}
		this.setName(nameCN);
		this.setNow(Float.parseFloat(now));
		this.setMax(Float.parseFloat(max));
		this.setSpeed(Float.parseFloat(speed));
		this.setIncrease(Float.parseFloat(increse));
		if (buff != null)
			this.setBuff(Float.parseFloat(buff));
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setNow(float now) {
		this.now = now;
	}

	public float getNow() {
		return now;
	}

	public void setMax(float max) {
		this.max = max;
	}

	public float getMax() {
		return max;
	}

	public void setSpeed(float speed) {
		this.speed = speed;
	}

	public float getSpeed() {
		return speed;
	}

	public void setIncrease(float increase) {
		this.increase = increase;
	}

	public float getIncrease() {
		return increase;
	}

	public void setBuff(float buff) {
		this.buff = buff;
	}

	public float getBuff() {
		return buff;
	}

	public String toString() {
		return name + "_" + now+";";
	}
	public boolean equals(Object o){
		SgfyResource temp = (SgfyResource)o;
		if(temp.getName().equalsIgnoreCase(this.name))
			return true;
		return false;
	}

}
